package sensorLAN.UIServidor;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import clienteServidor.infoHWSWEquipo.Bateria;

public class MiRender extends DefaultTableCellRenderer{
   /**
	 * 
	 */
	private static final long serialVersionUID = -474859876848507703L;

	@Override
	public Component getTableCellRendererComponent(JTable table,Object value, boolean isSelected, 
		boolean hasFocus, int row, int column){
	
		super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
		
		this.setForeground(Color.BLACK);
		if(!isSelected){
			if(row%2 == 1){
				this.setBackground(new Color(210,210,210));
			}else{
				this.setBackground(Color.WHITE);
			//this.setOpaque(false);
			}
		}else{//esta seleccionada la fila
			this.setForeground(Color.WHITE);
		}
    	if(column == NombreColumnas.CONECTADO_A_LAN.getNroColumna()){
			boolean v= (boolean) value;
	    	if(v) this.setBackground(Color.GREEN);
	    	else this.setBackground(Color.RED);
	    	//this.setOpaque(true);
	    	
	    	this.setForeground(Color.BLACK);
		}		
		if(column == NombreColumnas.ESTADO_BATERIA.getNroColumna()){
			String s= (String) value;
	    	if(s.equals(Bateria.ONLINE)) this.setBackground(Color.GREEN);
	    	else this.setBackground(Color.RED);
	    	this.setOpaque(true);
	    	this.setForeground(Color.BLACK);
		}
		
		return this;
	}

}
